package org.xqyy.eval.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.xqyy.eval.model.TSystemCycle;
import org.xqyy.eval.service.ISystemCycleService;
import java.util.List;

/**
 * 系统填报周期
 */
@Controller
@RequestMapping("/systemcycle")
public class SystemCycleController {

    @Autowired
    private ISystemCycleService systemCycleService;

    /**
     * 填报周期页面
     * @return
     */
    @RequestMapping("/cyclepage")
    public ModelAndView cyclepage(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("jsp/evalsystem/cyclepage");
        return modelAndView;
    }

    /**
     * 查询填报周期信息
     * @return
     */
    @RequestMapping("/selectSystemCycle")
    @ResponseBody
    public List<TSystemCycle> selectSystemCycle(){
        return systemCycleService.selectSystemCycle();
    }

    /**
     * 添加填报周期信息
     * @return
     */
    @RequestMapping("/addSystemCycle")
    @ResponseBody
    public Boolean addSystemCycle(TSystemCycle systemCycle){
        try {
            systemCycleService.addSystemCycle(systemCycle);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return  false;
        }
    }

    /**
     * 查询一个填报周期信息
     * @return
     */
    @RequestMapping("/selectSystemCycleById")
    @ResponseBody
    public TSystemCycle selectSystemCycleById(TSystemCycle systemCycle){
        return systemCycleService.findSystemCycleById(systemCycle.getId());
    }

    /**
     * 修改填报周期信息
     * @return
     */
    @RequestMapping("/updateSystemCycle")
    @ResponseBody
    public Boolean updateSystemCycle(TSystemCycle systemCycle){
        try {
            systemCycleService.updateSystemCycle(systemCycle);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return  false;
        }
    }

    /**
     * 删除填报周期信息
     * @return
     */
    @RequestMapping("/delSystemCycle")
    @ResponseBody
    public Boolean delSystemCycle(TSystemCycle systemCycle){
        try {
            systemCycleService.delSystemCycle(systemCycle);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            return  false;
        }
    }
}
